<?php
final class Registry {
  
    private static $instance;
	private $data = array();
  
  private function __construct(){
      self::$instance = $this;
  }
  
  public static function getInstance()
  {
        if (!isset(self::$instance)) {
            $className = __CLASS__;
            self::$instance = new $className;
        }

        return self::$instance;
  }

	public function getData() {
		return (isset($this->data) ? $this->data : NULL);
	}
  
  public function get($key) {
		return (isset($this->data[$key]) ? $this->data[$key] : NULL);
	}

	public function set($key, $value) {
		$this->data[$key] = $value;
	}

	public function has($key) {
    	return isset($this->data[$key]);
  	}
    
  public function __isset($key)
    {
        return $this->has($key);
    }

  function __set($name, $var){
        $this->set($name, $var);
    }

  function __get($name){
        $var = null;

        if( $this->has($name) )
            $var = $this->get($name);

        return $var;
    }
}
?>